extends MoveElement


class_name RotateElement
"""
根据朝向进行图片旋转
"""


## 需要适配的对象,默认为MoveComponent适配的对象
@export var wrapper: Node2D = null


func on_move_ready() -> void:
    if wrapper == null:
        wrapper = move_component.wrapper

func rotate_wrapper() -> void:
    wrapper.rotation = move_component.direction.angle()

func on_move_direction_changed() -> void:
    rotate_wrapper()

func yield_move(delta: float) -> Vector2:
    if move_component.is_moving():
        rotate_wrapper()
    return Vector2.ZERO
